<?php

namespace App\Repository\Ai;

use App\Model\Ai\Manufacturer;
use App\Repository\IRepository;
use Hyperf\Database\Model\Builder;

/**
 * 模型厂商  Repository
 */
class ManufacturerRepository extends IRepository
{
    public function __construct(
        protected readonly Manufacturer $model
    )
    {
    }

    public function handleSearch(Builder $query, array $params): Builder
    {

        return $query->when(isset($params['name']) && $params['name'], function ($query) use ($params) {
                    return $query->where('name','like', "%{$params['name']}%");
                });
    }
}